import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import vueJsx from "@vitejs/plugin-vue-jsx";
//自动引入
import AutoImport from "unplugin-auto-import/vite";

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    host: "0.0.0.0",
    port: 5123,
    headers: {
      "Content-Security-Policy": "img-src 'self' data:;"
    }
  },
  css: {
    preprocessorOptions: {
      // 全局scss混入
      scss: {
        additionalData: `@use "src/style/public.scss" as *; @use "@/style/index.scss" as *;`,
      },
    },
  }, // css 配置
  esbuild: {}, // 打包配置

  //  文件别名
  resolve: {
    alias: [
      {
        find: "@",
        replacement: path.resolve(__dirname, "src"),
      },
      {
        find: "utils",
        replacement: path.resolve(__dirname, "src/utils"),
      },
      {
        find: "eleicon",
        replacement: path.resolve(
          __dirname,
          "node_modules/@element-plus/icons"
        ),
      },
    ],
  },
	base: '/student',
  plugins: [
    vue(),
    vueJsx(),
    AutoImport({
      imports: ["vue", "vue-router"], //自动导入vue和vue-router相关的函数
    }),
  ],
});
